﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MvcMusicStore.Models;
using MvcMusicStore.Repositories;

namespace Repositories.Models
{
    public static class RepositoryProvider
    {
        private static MusicStoreEntities storeDb = new MusicStoreEntities();

        public static CartItemRepository CartItemRepository { get; private set; }
        public static CartRepository CartRepository { get; private set; }
        public static AlbumRepository AlbumRepository { get; private set; }

        static RepositoryProvider()
        {
            CartItemRepository = new CartItemRepository(storeDb);
            CartRepository = new CartRepository(storeDb);
            AlbumRepository = new AlbumRepository(storeDb);
        }

        public static int SaveChanges()
        {
            try
            {
                storeDb.SaveChanges();
                return 1;
            }
            catch (Exception ex)
            {
                return 0;
            }
        }
    }
}